﻿using System;
using System.AddIn.Pipeline;
using RootfusAddinContracts;
using RootfusHostView;

namespace RootfusAddinHostAdapters
{
    [HostAdapter]
    class SICallbackContractToView : SICallback
    {
        ISICallbackContract _contract;
        ContractHandle _handle;

        public SICallbackContractToView(ISICallbackContract contract)
        {
            _contract = contract;
            _handle = new ContractHandle(contract);
        }

        public override void UpdateSaveInformation(string xmltext)
        {
            _contract.UpdateSaveInformation(xmltext);
        }

        public override RootfusHostView.ROOTObjectSpec[] GetConnectedPinDataAsROOTObject(PinDefinition pin)
        {
            RootfusAddinContracts.ROOTObjectSpec[] rtn = _contract.GetConnectedPinDataAsROOTObject(PinDefinitionAddInAdapter.ViewToContractAdapter(pin));
            return UtilityConverters.ConvertROOTObjectSpecArray(rtn);
        }

        public override void OutputPinsChanged()
        {
            _contract.OutputPinsChanged();
        }

        public override string[] GetNamesOfConnectedPins(PinDefinition pin)
        {
            return _contract.GetNamesOfConnectedPins(PinDefinitionAddInAdapter.ViewToContractAdapter(pin));
        }
    }
}
